<?php
include_once "RequestInit.php";
include_once "VerifyToken.php";

if(
	!isset($_REQUEST['entryid']) || 
	!isset($_REQUEST['entry']) ||
	!isset($_REQUEST['notes']) ||
	!isset($_REQUEST['calories']) ||
	!isset($_REQUEST['carbs']) ||
	!isset($_REQUEST['date'])
	)
{
	header('HTTP/1.1 500 improper parameters submitted');
	exit;
} 

$entry= new Entry
(
		$_REQUEST['entryid'], 
		$_REQUEST['entry'],
		$_REQUEST['notes'],
		$_REQUEST['calories'],
		$_REQUEST['carbs'],
		$_REQUEST['date'],
		$_SESSION['userId'],
		$dbConn
		
);
$entry->save();
echo json_encode($entry->toValueObject());
include_once "RequestCleanup.php";
?>